﻿using System;
using System.Windows.Media;
using System.Windows;

namespace WPFToolkit.Drawing
{
    class PropertiesGraphicsEraser : PropertiesGraphicsBase
    {
        private double left;
        private double top;
        private double right;
        private double bottom;
        private double lineWidth;
        private Color objectColor;

        public PropertiesGraphicsEraser()
        {

        }

        public PropertiesGraphicsEraser(GraphicsEraser rectangle)
        {
            if (rectangle == null)
            {
                throw new ArgumentNullException("rectangle");
            }

            left = rectangle.Left;
            top = rectangle.Top;
            right = rectangle.Right;
            bottom = rectangle.Bottom;

            lineWidth = rectangle.LineWidth;
            objectColor = rectangle.ObjectColor;
            actualScale = rectangle.ActualScale;
            ID = rectangle.Id;
            selected = rectangle.IsSelected;
        }

        public override GraphicsBase CreateGraphics()
        {
            GraphicsBase b = new GraphicsRectangle(left, top, right, bottom, lineWidth, objectColor, actualScale);

            // GraphicsBase contains new ID generated by constructor.
            // This is OK if this instance is loaded from XML file.
            // But if this instance is part of commands history,
            // it contains ID which should be set in GraphicsBase.
            // This rule is applied to all SerializedGraphicsBase-derived
            // classes.

            if (this.ID != 0)       // from command history, not from file
            {
                b.Id = this.ID;
                b.IsSelected = this.selected;
            }

            return b;

        }

        #region Properties

        /// <summary>
        /// Left bounding rectangle side, X
        /// </summary>
        public double Left
        {
            get { return left; }
            set { left = value; }
        }

        /// <summary>
        /// Top bounding rectangle side, Y
        /// </summary>
        public double Top
        {
            get { return top; }
            set { top = value; }
        }

        /// <summary>
        /// Right bounding rectangle side, X
        /// </summary>
        public double Right
        {
            get { return right; }
            set { right = value; }
        }

        /// <summary>
        /// Bottom bounding rectangle side, Y
        /// </summary>
        public double Bottom
        {
            get { return bottom; }
            set { bottom = value; }
        }


        /// <summary>
        /// Line Width
        /// </summary>
        public double LineWidth
        {
            get { return lineWidth; }
            set { lineWidth = value; }
        }

        /// <summary>
        /// Color
        /// </summary>
        public Color ObjectColor
        {
            get { return objectColor; }
            set { objectColor = value; }
        }

        #endregion Properties

    }
}
